package com.ngc.mall.controller;

import com.ngc.mall.common.configure.response.ResponseResult;
import com.ngc.mall.domain.EmployeeDomain;
import com.ngc.mall.service.IEmployeeService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 *
 * 员工
 * @author: chenxiaolin
 * @date 2023/9/20 18:22
**/
@RestController
@RequestMapping("/employee")
public class EmployeeController {
    @Autowired
    private IEmployeeService iEmployeeService;

    @GetMapping("/list")
    @ApiOperation("获取所有员工")
    public ResponseResult<List<EmployeeDomain>> selectAll(){
        return ResponseResult.success(iEmployeeService.selectAll());
    }

    @PostMapping("")
    @ApiOperation("新增员工")
    public ResponseResult<Long> create(@RequestBody EmployeeDomain employeeDomain){
        return ResponseResult.success(iEmployeeService.createEmployee(employeeDomain));
    }

    @PutMapping("/id/{id}")
    @ApiOperation("根据id更新员工")
    public ResponseResult<Boolean> updateById(@PathVariable Long id,@RequestBody EmployeeDomain employeeDomain){
        return ResponseResult.auto(iEmployeeService.updateEmployeeById(id,employeeDomain));
    }

}
